<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path=request.getContextPath();
%>    

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="/resources/css/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="/resources/js/jquery-3.2.1/jquery.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/jquery.validate.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/localization/messages_zh.js"></script>
	<script type="text/javascript" src="/resources/css/bootstrap-4.3.1/js/bootstrap.js"></script>
</head>
<body>
	<form action="/admin/addLink" method="post" name = "linkForm">
  
  <div class="form-group">
    <label for="exampleInputPassword1" >网站名</label>
    <input type="text" class="form-control"  name = "name">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1" >链接</label>
    <input type="text" class="form-control"  name = "url">
  </div>
  <input type="button" onclick = "subForm()" class="btn btn-primary" value = "添加友情链接">
</form>

	<script type="text/javascript">
		
		function subForm(){
			$.post("/admin/addLink",$("form[name='linkForm']").serialize(),function(msg){
				
				if(msg.id == 0 ){
					alert("添加成功！");
					location = "/admin/toShowAll";
				}else{
					alert("添加失败！");	
				}	
			})	
		}
	
	
	
	
	</script>
	



</body>
</html>